//
//  LPDatePickerViewController.m
//  Pickers
//
//  Created by johnny tang on 7/25/13.
//  Copyright (c) 2013 TOSC. All rights reserved.
//

#import "LPDatePickerViewController.h"

@interface LPDatePickerViewController ()
@property (weak, nonatomic) IBOutlet UIDatePicker *datePicker;
- (IBAction)buttonPressed:(id)sender;
@end

@implementation LPDatePickerViewController

@synthesize datePicker;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    NSDate *now = [NSDate date];
    NSLog(@"now = %@", now);
    [datePicker setDate:now];
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)viewDidUnload {
    [super viewDidUnload];
    // Release any retained subviews of the main view. // e.g. self.myOutlet = nil;
    self.datePicker = nil;
}

- (IBAction)buttonPressed:(id)sender {
    NSDate *selected = [datePicker date];
    NSString *message = [[NSString alloc] initWithFormat:
                         @"The date and time you selected is %@", selected];
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Date and time selected"
                                                    message:message
                                                   delegate:nil
                                          cancelButtonTitle:@"Yes, I did"
                                          otherButtonTitles:nil];
    [alert show];
}
@end
